//
//  MyProfitCell.m
//  NewPro
//
//  Created by 何荧红 on 2018/10/12.
//  Copyright © 2018 何荧红. All rights reserved.
//

#import "MyProfitCell.h"

@interface MyProfitCell ()
@property (nonatomic, strong) UILabel *submoney;
@property (nonatomic, strong) UILabel *subProfit;
@property (nonatomic, strong) UILabel *Mposlab;
@property (nonatomic, strong) UILabel *MPosMoney;
@property (nonatomic, strong) UILabel *MPosProfit;
@property (nonatomic, strong) UILabel *Poslab;
@property (nonatomic, strong) UILabel *PosMoney;
@property (nonatomic, strong) UILabel *PosProfit;

@property (nonatomic, strong) UIView *footView;
@property (nonatomic, strong) UIImageView *searimg;
@property (nonatomic, strong) UIImageView *rightAr;
@property (nonatomic, assign) BOOL cellpush;
@end

@implementation MyProfitCell
- (void)setRightArrow:(BOOL)rightArrow{
    _rightArrow = rightArrow;
    if (_rightArrow) {
        [self.MPosProfit mas_updateConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.rightAr.mas_left).offset(-25);
        }];
        [self.PosProfit mas_updateConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.rightAr.mas_left).offset(-25);
        }];
    }else{
        [self.MPosProfit mas_updateConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.rightAr.mas_left).offset(7);
        }];
        [self.PosProfit mas_updateConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.rightAr.mas_left).offset(7);
        }];
    }
}
- (void)setCellpush:(BOOL)cellpush{
    _cellpush = cellpush;
    if (_cellpush) {
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, 109);
        self.footView.backgroundColor = [UIColor colorWithHexString:@"dedede"];
        [UIView animateWithDuration:0.3 animations:^{
            self.footView.frame = CGRectMake(0, 44, SCREEN_WIDTH, 64);
        }];
        self.searimg.image = [UIImage imageNamed:@"上拉按钮"];
        self.Mposlab.hidden = NO;
        self.MPosProfit.hidden = NO;
        self.MPosMoney.hidden = NO;
        self.Poslab.hidden = NO;
        self.PosMoney.hidden = NO;
        self.PosProfit.hidden = NO;
        if (_rightArrow) {
            self.rightAr.hidden = NO;
        }else{
            self.rightAr.hidden = YES;
        }
    }else{
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, 45);
        self.footView.backgroundColor = [UIColor colorWithHexString:@"f5f5f5"];
        [UIView animateWithDuration:0.3 animations:^{
            self.footView.frame = CGRectMake(0, 44, SCREEN_WIDTH, 1);
        }];
        self.searimg.image = [UIImage imageNamed:@"下拉按钮"];
        self.Mposlab.hidden = YES;
        self.MPosProfit.hidden = YES;
        self.MPosMoney.hidden = YES;
        self.Poslab.hidden = YES;
        self.PosMoney.hidden = YES;
        self.PosProfit.hidden = YES;
        self.rightAr.hidden = YES;
    }
}
- (void)setCllpush:(MyProfitpush *)cllpush{
    _cllpush = cllpush;
    if (_cllpush) {
        if ([_cllpush.CllPush isEqualToString:@"0"]) {
            self.cellpush = NO;
        }
        if ([_cllpush.CllPush isEqualToString:@"1"]) {
            self.cellpush = YES;
        }
    }
}
- (void)setModel:(MyProfitModel *)model With:(NSInteger)index{
    _model = model;
    if (_model) {
        if (index == 0) {
            self.submoney.text = _model.actRewards;
            self.subProfit.text = [NSString stringWithFormat:@"+%@",_model.actRewardsSY];//收益
            self.MPosProfit.text = [NSString stringWithFormat:@"+%@",_model.actRewardsSumMposSY];
            self.MPosMoney.text = _model.actRewardsSumMpos;
            self.PosMoney.text = _model.actRewardsSumPos;
            self.PosProfit.text = [NSString stringWithFormat:@"+%@",_model.actRewardsSumPosSY];
        }else if (index == 1){
            self.submoney.text = _model.expRewards;
            self.subProfit.text = [NSString stringWithFormat:@"+%@",_model.expRewardsSY];
            self.MPosProfit.text = [NSString stringWithFormat:@"+%@",_model.expRewardsSumMposSY];
            self.MPosMoney.text = _model.expRewardsSumMpos;
            self.PosMoney.text = _model.expRewardsSumPos;
            self.PosProfit.text = [NSString stringWithFormat:@"+%@",_model.expRewardsSumPosSY];
        }else if (index == 2){
            self.submoney.text = _model.proRewards;
            self.subProfit.text = [NSString stringWithFormat:@"+%@",_model.proRewardsSY];
            self.MPosProfit.text = [NSString stringWithFormat:@"+%@",_model.proRewardsSumMposSY];
            self.MPosMoney.text = _model.proRewardsSumMpos;
            self.PosMoney.text = _model.proRewardsSumPos;
            self.PosProfit.text = [NSString stringWithFormat:@"+%@",_model.proRewardsSumPosSY];
        }else if (index == 3){
            self.submoney.text = _model.rconAllowance;
            self.subProfit.text = [NSString stringWithFormat:@"+%@",_model.rconAllowanceSY];
            self.MPosProfit.text = [NSString stringWithFormat:@"+%@",_model.rconAllowanceSumMposSY];
            self.MPosMoney.text = _model.rconAllowanceSumMpos;
            self.PosMoney.text = _model.rconAllowanceSumPos;
            self.PosProfit.text = [NSString stringWithFormat:@"+%@",_model.rconAllowanceSumPosSY];
        }else if (index == 4){
            self.submoney.text = _model.manAllowance;
            self.subProfit.text = [NSString stringWithFormat:@"+%@",_model.manAllowanceSY];
            self.MPosProfit.text = [NSString stringWithFormat:@"+%@",_model.manAllowanceSumMposSY];
            self.MPosMoney.text = _model.manAllowanceSumMpos;
            self.PosMoney.text = _model.manAllowanceSumPos;
            self.PosProfit.text = [NSString stringWithFormat:@"+%@",_model.manAllowanceSumPosSY];
        }
    }else{
        if (index == 0) {
            self.submoney.text = @"0";
            self.subProfit.text = @"+0.00";//收益
            self.MPosProfit.text = @"+0.00";
            self.MPosMoney.text = @"0";
            self.PosMoney.text = @"0";
            self.PosProfit.text = @"+0.00";
        }else if (index == 1){
            self.submoney.text = @"0.0000";
            self.subProfit.text = @"+0.00";
            self.MPosProfit.text = @"+0.00";
            self.MPosMoney.text = @"0.0000";
            self.PosMoney.text = @"0.0000";
            self.PosProfit.text = @"+0.00";
        }else if (index == 2){
            self.submoney.text = @"0.0000";
            self.subProfit.text = @"+0.00";
            self.MPosProfit.text = @"+0.00";
            self.MPosMoney.text = @"0.0000";
            self.PosMoney.text = @"0.0000";
            self.PosProfit.text = @"+0.00";
        }else if (index == 3){
            self.submoney.text = @"0.0000";
            self.subProfit.text = @"+0.00";
            self.MPosProfit.text = @"+0.00";
            self.MPosMoney.text = @"0.0000";
            self.PosMoney.text = @"0.0000";
            self.PosProfit.text = @"+0.00";
        }else if (index == 4){
            self.submoney.text = @"0.0000";
            self.subProfit.text = @"+0.00";
            self.MPosProfit.text = @"+0.00";
            self.MPosMoney.text = @"0.0000";
            self.PosMoney.text = @"0.0000";
            self.PosProfit.text = @"+0.00";
        }
    }
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, 45);
        [self CleanSubView];
    }
    return self;
}
- (void)CleanSubView{
    self.typelab = [[UILabel alloc]init];
    _typelab.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:14];
    _typelab.textColor = [UIColor colorWithHexString:@"333333"];
    [self addSubview:_typelab];
    [_typelab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(14);
        make.top.equalTo(self.mas_top).offset(16);
        make.height.mas_equalTo(14);
    }];
    self.submoney = [[UILabel alloc]init];
    self.submoney.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:14];
    self.submoney.textColor = [UIColor colorWithHexString:@"333333"];
    self.submoney.text = @"0";
    [self addSubview:self.submoney];
    [self.submoney mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.typelab.mas_centerY);
        make.centerX.equalTo(self.mas_centerX);
    }];
    self.subProfit = [[UILabel alloc]init];
    self.subProfit.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:14];
    self.subProfit.textColor = [UIColor colorWithHexString:@"F86912"];
    self.subProfit.text = @"+0.00";
    [self addSubview:self.subProfit];
    [self.subProfit mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.typelab.mas_centerY);
        make.right.equalTo(self.mas_right).offset(-14);
    }];
    self.searimg = [[UIImageView alloc]init];
    self.searimg.image = [UIImage imageNamed:@"下拉按钮"];
    [self addSubview:self.searimg];
    [self.searimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(9);
        make.height.mas_equalTo(5);
        make.left.equalTo(self.typelab.mas_right).offset(6);
        make.centerY.equalTo(self.typelab.mas_centerY);
    }];
    self.footView = [[UIView alloc]initWithFrame:CGRectMake(0, 44, SCREEN_WIDTH, 1)];
    self.footView.backgroundColor = [UIColor colorWithHexString:@"F5F5F5"];
    [self addSubview:self.footView];
    
    self.Mposlab = [[UILabel alloc]init];
    _Mposlab.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:12];
    _Mposlab.textColor = [UIColor colorWithHexString:@"666666"];
    _Mposlab.text = @"MPOS";
    [self.footView addSubview:_Mposlab];
    [_Mposlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.footView.mas_left).offset(14);
        make.top.equalTo(self.footView.mas_top).offset(12);
        make.height.mas_equalTo(9);
    }];
    
    self.MPosMoney = [[UILabel alloc]init];
    _MPosMoney.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:12];
    _MPosMoney.textColor = [UIColor colorWithHexString:@"666666"];
    _MPosMoney.text = @"0.00";
    [self.footView addSubview:_MPosMoney];
    [_MPosMoney mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.submoney.mas_centerX);
        make.centerY.equalTo(self.Mposlab.mas_centerY);
    }];
    
    self.rightAr = [[UIImageView alloc]init];
    _rightAr.image = [UIImage imageNamed:@"特灰色右箭头"];
    [self.footView addSubview:_rightAr];
    [_rightAr mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.footView.mas_centerY);
        make.right.equalTo(self.footView.mas_right).offset(-14);
        make.width.mas_equalTo(7);
        make.height.mas_equalTo(12);
    }];
    self.rightAr.hidden = YES;
    
    self.MPosProfit = [[UILabel alloc]init];
    _MPosProfit.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:12];
    _MPosProfit.textColor = [UIColor colorWithHexString:@"F86912"];
    _MPosProfit.text = @"+0.00";
    [self.footView addSubview:_MPosProfit];
    [_MPosProfit mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.rightAr.mas_left).offset(-25);
        make.centerY.equalTo(self.Mposlab.mas_centerY);
    }];
    
    self.Poslab = [[UILabel alloc]init];
    _Poslab.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:12];
    _Poslab.textColor = [UIColor colorWithHexString:@"666666"];
    _Poslab.text = @"传统POS";
    [self.footView addSubview:_Poslab];
    [_Poslab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.footView.mas_left).offset(14);
        make.bottom.equalTo(self.footView.mas_bottom).offset(-12);
        make.height.mas_equalTo(12);
    }];
    
    self.PosMoney = [[UILabel alloc]init];
    _PosMoney.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:12];
    _PosMoney.textColor = [UIColor colorWithHexString:@"666666"];
    _PosMoney.text = @"0.00";
    [self.footView addSubview:_PosMoney];
    [_PosMoney mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.submoney.mas_centerX);
        make.centerY.equalTo(self.Poslab.mas_centerY);
    }];
    
    self.PosProfit = [[UILabel alloc]init];
    _PosProfit.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:12];
    _PosProfit.textColor = [UIColor colorWithHexString:@"F86912"];
    _PosProfit.text = @"+0.00";
    [self.footView addSubview:_PosProfit];
    [_PosProfit mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.rightAr.mas_left).offset(-25);
        make.centerY.equalTo(self.Poslab.mas_centerY);
    }];
    self.footbutton = [[UIButton alloc]init];
    [_footbutton addTarget:self action:@selector(footbuttonclik) forControlEvents:UIControlEventTouchUpInside];
    [self.footView addSubview:_footbutton];
    [_footbutton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
}
- (void)footbuttonclik{
    if (self.footbutBlock) self.footbutBlock();
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    if (selected) {
        self.cellpush = !self.cellpush;
        if (self.cellPushBlock) self.cellPushBlock(self.cellpush);
    }
}

@end
